ML feature substrate: bounded, reproducible per-locus feature stream (rosalind features) - #28
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A FEATURE sink over the same streaming PileupEngine: every callable locus is
emitted as a tabular row (contig, 1-based pos, ref, depth, raw_depth, ACGT
counts, per-allele fwd/rev strand counts, mean base-qual, mean mapq) instead of
only variant sites. stream_features_region + stream_features_whole_genome reuse
the bounded per-contig driver (PerContig made pub(crate)), returning
(WorkingSet, SkipCounts) like the germline path. Output is byte-identical
run-to-run (canonical obs order + integer-mean {:.2} formatting) — the basis for
bit-reproducible ML training inputs. Unit-tested for exact fields + determinism
+ bounded working set.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… TSV run_features mirrors run_variants_index (StreamingBamSource + the same --enforce gate exit 3/4 + realized-peak receipt) but streams a feature row per callable locus instead of variant calls. Verified on the toy genome: 983,011 rows at 6 MiB peak (bounded), byte-identical across runs (the reproducibility claim), with the row count in the receipt. Integration tests cover the schema, byte-identical output, the receipt + verify, and the exit-3 refuse under a tight budget. 'plan --index' already predicts this peak (same engine). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bounded + byte-identical per-locus features -> bit-reproducible ML training inputs with a verifiable receipt; one-line pandas read; Arrow/pyarrow on the roadmap. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The kernel already produces a bounded, deterministic per-locus
PileupColumnstream; this exposes it as an ML feature substrate, landing the claim no other tool makes: byte-identical features → bit-reproducible training inputs, with a verifiable hash receipt.call::features— a feature sink over the same streamingPileupEngine: every callable locus becomes a tabular row (contig, 1-based pos, ref, depth, raw_depth, A/C/G/T counts, per-allele fwd/rev strand counts, mean base-qual, mean mapq).stream_features_region+stream_features_whole_genomereuse the bounded per-contig driver (PerContigmadepub(crate)), returning(WorkingSet, SkipCounts)like the germline path.rosalind featuresCLI — streams the per-locus TSV under the same memory contract (planpredicts it,--enforcehonors it exit 3/4,verifyre-checks the receipt), with the row count in the manifest.pd.read_csv(sep='\t')). Verified on the toy genome: 983,011 rows at 6 MiB peak (bounded), byte-identical across runs (the reproducibility claim).Spec:
docs/superpowers/specs/2026-06-02-ml-feature-substrate-design.md.Deferred to a follow-up: Arrow/Parquet egress (zero-copy efficiency), a real
pyarrowPython boundary (replacing the dead-end stub), and a reference-model demo. The TSV + receipt already deliver the core reproducibility claim; those are ergonomics/efficiency.Test plan
cargo testgreen (unit: exact fields + determinism + bounded; integration: schema + byte-identical + receipt + verify + exit-3 refuse)cargo fmt --all -- --checkclean; 0 warnings (debug + release)verify: OK🤖 Generated with Claude Code